/**
  其他境外交流项目管理-导师/学院领导审核回国
*/
<template>
  <div class="project-application-container">
    <div style="height: 30px;">
      <el-breadcrumb style="float: left;" separator="/">
        <el-breadcrumb-item :to="{ path: '/exchangeProjectAudit' }">
          <span @click="reback()">{{ $t('projectManage.otherOverseasExchangeAudit') }}</span>
        </el-breadcrumb-item>
        <el-breadcrumb-item>
          <span>{{ $t('projectApplication.shortTermVisitRuturnGovernAudit') }}</span>
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-card shadow="never" v-loading="loading" body-style="padding: 24px;">
      <div slot="header" class="title">
        <span>{{ $t('projectManage.otherOverseasExchangeAudit') }}</span>
         -
        <span >{{ $t('projectApplication.shortTermVisitRuturnGovernAudit') }}</span>
        <el-button style="float:right; margin-top: -5px;" @click="reback()">{{ $t('common.btn.back') }}</el-button>
      </div>
      <return-home-common-info :applyId="applyId" :backId="backId" :projectStartTime="projectStartTime" :projectEndTime="projectEndTime">
        <slot>
          <!-- 审批进度开始 -->
          <div class="audit-container">
            <!-- 审批明细开始 -->
            <div class="privacy-title title other-title" style="margin-top: 40px;">
              {{ $t('exchangeProjectAudit.approvalDetail') }}
            </div>
            <el-form :model="auditInfo" ref="auditInfo">
              <el-row :gutter="24">
                <el-col :span="24">
                  <!-- 审核意见 -->
                  <el-form-item
                    :label="$t('exchangeProjectAudit.auditOpinion') + '：'"
                    prop="content">
                      <el-input v-model="auditInfo.content" :maxlength="500" type="textarea" :rows="7" clearable :placeholder="$t('common.pla.pleaseInput')"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <div class="operate-footer">
              <el-button type="danger" @click="reject()">{{ $t('externamExchangeBase.reject') }}</el-button>
              <el-button type="primary" @click="pass()">{{$t('externamExchangeBase.pass')}}</el-button>
            </div>
            <!-- 审批明细结束 -->
          </div>
        </slot>
        <!-- 审批进度开始 -->
        <template slot="footer"></template>
        <!-- 审批进度结束 -->
      </return-home-common-info>
    </el-card>
  </div>
</template>
<script>
import returnHomeCommonInfo from 'common/src/views/externalExchange/common/returnHomeCommonInfo';
import externalExchangeApi from 'common/src/api/externalExchange/externalExchange';
export default {
  components: {
    'return-home-common-info': returnHomeCommonInfo
  },
  data() {
    return {
      auditInfo: {
        content: ''
      }
    };
  },
  props: {
    applyId: {
      type: String,
      default: ''
    },
    backId: {
      type: String,
      default: ''
    },
    projectStartTime: {
      type: String,
      default: ''
    },
    projectEndTime: {
      type: String,
      default: ''
    }
  },
  computed: {
  },
  filters: {
  },
  created() {

  },
  async mounted() {

  },
  methods: {
    // 校验特殊字符$
    checkSpecial(rule, value, callback) {
      let regEn = /[`$]/im;
      if (regEn.test(value)) {
        callback(new Error(this.$t('graduateBase.specialText')))
      } else {
        callback();
      }
    },
    reback() {
      this.$emit('change-project-index')
    },
    // 驳回
    reject() {
      if (this.auditInfo.content) {
        externalExchangeApi.auditReturnHomeReimburse({
          "type": 2,
          "content": this.auditInfo.content,
          "backIds": [this.backId]
        }).then(res => {
          if (res.code === 200) {
            this.$message({
              type: 'success',
              message: this.$t('externamExchangeBase.auditSuccessfully')
            })
            this.reback()
          }
        })
      } else {
        this.$message.error(this.$t('exchangeProjectAudit.requireAuditOpinion'))
      }
    },
    // 通过
    pass() {
      this.$refs['auditInfo'].validate((valid) => {
        if (valid) {
          externalExchangeApi.auditReturnHomeReimburse({
            "type": 1,
            "content": this.auditInfo.content,
            "backIds": [this.backId]
          }).then(res => {
            if (res.code === 200) {
              this.$message({
                type: 'success',
                message: this.$t('externamExchangeBase.auditSuccessfully')
              })
              this.reback()
            }
          })
        }
      })
    }
  },
  watch: {

  }
}
</script>

<style lang="scss" scoped>
  .project-application-container {
    .el-breadcrumb__item:last-child ::v-deep {
      .el-breadcrumb__inner {
        color: #606266;
        font-weight: bold;
        cursor: default
      }
    }
    .el-breadcrumb__item ::v-deep {
      .is-link {
        color: #aaa;
        font-weight: unset;
      }
      .is-link:hover {
        color: #409eff;
      }
    }
    .title {
      font-weight: bold;
      font-size: 18px;
    }
    .privacy-title {
      margin-bottom: 20px;
    }
    .other-title {
      margin-top: 20px;
    }
    .audit-container {
      padding-left: 15px;
    }
    .operate-footer {
      text-align: right;
    }
  }
</style>
